import { createRouter, createWebHistory } from 'vue-router';
import type { RouteRecordRaw } from 'vue-router';
import main from '../components/main.vue';
import login from "../components/login.vue";
import chat from "../components/chat.vue";



const routes: Array<RouteRecordRaw> = [
    {
        path: '/mainsdgery4y43ydsgefst',
        name: 'main',
        component: main,
        // 如果你需要meta信息，可以这样写，注意meta的类型是Record<string, any>或更具体的类型
        // meta: { requiresAuth: true },
        children: [
            {path: '/', name: 'chat', component: chat, meta: { title: 'MCP 对话' }},

        ]
    },
    {
        path: '/login',
        name: 'login',
        component: login,
        meta: { title: '注册登录' }
    }

];


const router = createRouter({
    history: createWebHistory(),
    routes
});

router.beforeEach((to, from, next) => {
  // 修改页面标题
  if (to.meta && to.meta.title) {
    document.title = to.meta.title;
  }
  next();
});

export default router;